<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title></title><link rel="icon" href="chrome://ietab2/skin/ietab-favicon-iedoc.png">
</head>
<body style="margin:0; padding:0;overflow:hidden" onload="window.setTimeout(function() { init(); },0);">

<script type="text/javascript">
var gIETab = null;

function init(){
    gIETab = document.getElementById("IETab2");
    try {
        // This is needed to avoid an "Activate Plugin" prompt in Fx 27+.
        // It's not documented, thus the try/catch for back-compat
        gIETab.QueryInterface(Components.interfaces.nsIObjectLoadingContent).playPlugin();
    } catch(ex) {
    }

    if(!gIETab || !gIETab.navigate)
    {
		// Wait for it to show up
    	window.setTimeout(function() { init(); }, 200);
		return;
	}

    var m=/(\?url=)(\S+)$/.exec(document.location.href);
    if(m)
    {
        var url = decodeURI(m[2]);
        if ((url.indexOf("about:") == 0) || (url.indexOf("chrome://") == 0))
            url = 'http://www.ietab.net/ie-tab-v2-documentation?from=' + url;
        gIETab.navigate(url);
    }
}

var IETabCalls = {
	goBack: function() {
		gIETab.goBack();
	},

	goForward: function() {
		gIETab.goForward();
	},

	navigate: function(url) {
		gIETab.navigate(url);
	},

	refresh: function() {
		gIETab.refresh();
	},

	stop: function() {
		gIETab.stop();
	},

	saveAs: function() {
		gIETab.saveAs();
	},

	print: function() {
		gIETab.print();
	},

	printSetup: function() {
		gIETab.printSetup();
	},

	printPreview: function() {
		gIETab.printPreview();
	},

	viewSource: function() {
		gIETab.viewSource();
	},

	find: function() {
		gIETab.find();
	},

	cut: function() {
		gIETab.cut();
	},

	copy: function() {
		gIETab.copy();
	},

	paste: function() {
		gIETab.paste();
	},

	selectAll: function() {
		gIETab.selectAll();
	},

	focus: function() {
		if (!gIETab) {
			// It might not have loaded yet, wait for the control to fully initialize
			window.setTimeout(function() { IETabCalls.focus(); }, 100);
		}
		else {
			gIETab.focus();
		}
	}
}

window.onpageshow = function(e) { if (e.persisted) window.setTimeout(function() { init(); }, 0); }

function createIETab() {
    var obj = document.createElement("object");
    obj.id = "IETab2";
    obj.style.width = "100%";
    obj.style.height = "100%";
    // Waterfox/x64 example:
    //   Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:16.0) Gecko/20121026 Firefox/16.0
    // Firefox/x32 on Win64:
    //   Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Firefox/17.0
    // Firefox/x32 on Win32
    //   Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0
    //
    if (window.navigator.userAgent.indexOf("Win64; x64;") != -1)
        obj.setAttribute("type", "application/ietab2_x64");
    else
        obj.setAttribute("type", "application/ietab2");
    document.body.appendChild(obj);
}
// Navigation happens later, but create the IE Tab object immediately
createIETab();
</script>
</body>
</html>
